package cqrtplm.listener;

import cn.hutool.extra.spring.SpringUtil;
import com.hustcad.plm.pdm.workflow.annotion.CustomListener;
import com.hustcad.plm.pdm.workflow.model.constant.ProcessConstant;
import cqrtplm.mapper.StoragePlanningMapper;
import cqrtplm.service.RTPartService;
import cqrtplm.service.RejectTheStatusJudgmentLogicService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;

import javax.annotation.Resource;
import java.math.BigInteger;

import static org.reflections.Reflections.log;

/**
 * @author fxw
 * @version 1.0
 * @ClassName RejectTheStatusJudgmentLogicListener
 * @Description TODO
 * @since 2025/11/6 14:15
 */
@CustomListener(category = "润通", description = "驳回状态判断逻辑")
@Slf4j
public class RejectTheStatusJudgmentLogicListener implements ExecutionListener {

    @Override
    public void notify(DelegateExecution execution) {
        String workFlowContainerId = execution.getProcessInstanceBusinessKey();

        if (StringUtils.isBlank(workFlowContainerId)) {
            workFlowContainerId = execution.getVariable(ProcessConstant.WORK_FLOW_CONTAINER_ID).toString();
        }

        String finalWorkFlowContainerId = workFlowContainerId;
        RejectTheStatusJudgmentLogicService  rtPartService = SpringUtil.getBean(RejectTheStatusJudgmentLogicService.class);
        rtPartService.theChangeProcessDoesNotAllowPosting(new BigInteger(finalWorkFlowContainerId));
    }
}
